import CryptoJS from'crypto-js';
// 加密函数
function encryptData(data, key,iv){
  return CryptoJS.AES.encrypt(data, key,{
    iv: iv,
    mode: CryptoJS.mode.CBC,
    padding:  CryptoJS.pad.Pkcs7
  }).toString();
}

let plaintext ='要加密的数据';
let key = CryptoJS.enc.Utf8.parse('32位长度的密钥');
let iv = Cryptos.enc.Utf8.parse('16位长度的向量');
let ciphertext= encryptData(plaintext,key,iv);
console.log(ciphertext,'ciphertext')